#ifndef __UTIL_H__
#define __UTIL_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xdebug.h"
#include "common.h"
#include "base64.h"
#include "qp.h"


char*   fields_get_pair(char* data, char  *key, char  *value, char *defkey);
int     fields_get_pairs(char* data, char  *defkey, void *obj, int (*obj_set)(void* fobj,char *key,char *value) );
int     fields_get_pairs_recv(char* data, void *obj, int (*obj_set)(void* obj,char *key,char *value) );
int     fields_split(char *data, int len, void *obj, int (*obj_set)(void *fobj, char* key, char *value, int valen));


char*   xstrdup(const char*);
char*   xstrndup(const char*, int);
char*   xstrsdup(const char*, char*, int);
char*   xstrnstrip(char *data, int *len);
void    xstrnlower(char *data, int len);
int     xstrslen(const char *data, char*, int);
char*   xstrappend(char *, char *, int );
char*   xstrappend_nofree(char *, char *, int );
char*   xstrnchr(const char*, int, char);

int     text_decode(char *, char*, char*);

int     isfile(char *filename);
int     isdir(char *filename);

char    check_maintype(char *content);
int     file_range_decode(char *mailfile, int offset, int len, char tencode, char*);

#endif

